//
//  ArrowButton.swift
//  SwiftProject
//
//  Created by 董駸 on 2022/8/4.
//

import UIKit

enum ArrowDirection : Int {
    case up = 0
    case down
    case left
    case right
}

class ArrowButton: QMUIButton {
    private init() {
        super.init(frame: .zero)
    }
    
    private override init(frame: CGRect) {
        super.init(frame: frame)
    }
    
    convenience init(arrowSize : CGSize, arrowColor : UIColor, arrowDirection : ArrowDirection = .right, lineWidth : CGFloat = 2) {
        self.init()
        switch arrowDirection {
        case .right:
            setImage(.qmui_image(with: .navBack, size: arrowSize, lineWidth: lineWidth, tintColor: arrowColor)?.qmui_image(with: .down), for: .normal)
        case .left:
            setImage(.qmui_image(with: .navBack, size: arrowSize, lineWidth: lineWidth, tintColor: arrowColor), for: .normal)
        case .up:
            setImage(.qmui_image(with: .navBack, size: arrowSize, lineWidth: lineWidth, tintColor: arrowColor)?.qmui_image(with: .right), for: .normal)
        case .down:
            setImage(.qmui_image(with: .navBack, size: arrowSize, lineWidth: lineWidth, tintColor: arrowColor)?.qmui_image(with: .left), for: .normal)
        }
    }
    
    convenience init(arrowSize : CGSize, arrowColor : UIColor, arrowDirection : ArrowDirection = .right, lineWidth : CGFloat = 2, frame : CGRect) {
        self.init(arrowSize: arrowSize, arrowColor: arrowColor, arrowDirection: arrowDirection, lineWidth: lineWidth)
        self.frame = frame
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
}
